BODY_CPP = Body.cpp
BODY_H = Body.h
NODES_CPP = Nodes.cpp
NODES_H = Nodes.h
MAIN = main.cpp

OUT1_1 = ./out/body.o
OUT1_2 = ./out/nodes_debug.o
OUT1_3 = ./out/nodes.o
OUT1_4 = ./out/nodes_default.o
OUT2 = ./out/main.o

CC = mpic++
CFLAGS = -Wall -O2
EXEC = nbody

#Default-Version with output
all: $(OUT1_1) $(OUT1_4) $(OUT2)
	$(CC) $(CFLAGS) $(OUT1_1) $(OUT1_4) $(OUT2) -lm -o $(EXEC) 

#Runtime-Measurement-Version
run: $(OUT1_1) $(OUT1_3) $(OUT2)
	$(CC) $(CFLAGS) $(OUT1_1) $(OUT1_3) $(OUT2) -lm -o $(EXEC) 

#Debug-Version with a huge amount of output
debug: $(OUT1_1) $(OUT1_2) $(OUT2)
	$(CC) $(CFLAGS) $(OUT1_1) $(OUT1_2) $(OUT2) -lm -o $(EXEC)_debug

$(OUT2): $(MAIN) $(FUNC_H)
	$(CC) $(CFLAGS) -c $(MAIN) -o $(OUT2)

$(OUT1_4): $(NODES_CPP) $(NODES_H) 
	$(CC) $(CFLAGS) -c $(NODES_CPP) -lm -o $(OUT1_4)

$(OUT1_3): $(NODES_CPP) $(NODES_H) 
	$(CC) $(CFLAGS) -D DEBUG=0 -D RUNTIME_MEASUREMENT=1 -c $(NODES_CPP) -lm -o $(OUT1_3)

$(OUT1_2): $(NODES_CPP) $(NODES_H) 
	$(CC) $(CFLAGS) -D DEBUG=1 -D RUNTIME_MEASUREMENT=0 -c $(NODES_CPP) -lm -o $(OUT1_2)

$(OUT1_1): $(BODY_CPP) $(BODY_H)
	$(CC) $(CFLAGS) -c $(BODY_CPP) -o $(OUT1_1)

clean:
	rm ./out/*
